#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int maxAbsoluteSum(vector<int>& nums) {
        int positivemax = 0, negativemin = 0, positivesum = 0, negativesum = 0;
        for (int i = 0; i < nums.size(); i++) {
            positivemax += nums[i];
            positivesum = max(positivesum, positivemax);
            positivemax = max(positivemax, 0);
            negativemin += nums[i];
            negativesum = min(negativemin, negativesum);
            negativemin = min(0, negativemin);
        }
        return max(positivesum, -negativesum);
    }
};